package com.ssii.www.myproject.repository;

import com.ssii.www.myproject.domain.Menu;
import com.ssii.www.myproject.domain.MenuDto;
import com.ssii.www.myproject.domain.User;
import org.hibernate.annotations.NamedNativeQuery;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MenuRepository extends BaseRepository<Menu,Long> {
  @Query(value="select distinct mc.* from t_user u join t_user_role ur on u.id = ur.user_id join t_role r on r.id = ur.role_id join t_role_permission rp on rp.role_id = r.id  join t_permission p on p.id = rp.permission_id  join t_menu mc on p.menu_id = mc.id   where u.id =:id "
   ,nativeQuery = true)
  List<Menu> loadTreeByUserId(@Param("id") Long id);
  @Query(value="select m.* from t_menu as m  ",nativeQuery = true)
  List<Menu> testSql();
  @Query(value="select u.id,u.name from t_menu u  where  u.id=:id ",nativeQuery = true)
  Object testSql1(@Param("id")Long id);
}
